<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Spec::Example::ExampleGroupFactory</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Spec::Example::ExampleGroupFactory</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/plugins/rspec/lib/spec/example/example_group_factory_rb.html">
                vendor/plugins/rspec/lib/spec/example/example_group_factory.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="../../Object.html">
                Object
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000342">create_example_group</a>&nbsp;&nbsp;
      <a href="#M000340">default</a>&nbsp;&nbsp;
      <a href="#M000343">determine_superclass</a>&nbsp;&nbsp;
      <a href="#M000341">get</a>&nbsp;&nbsp;
      <a href="#M000339">register</a>&nbsp;&nbsp;
      <a href="#M000338">reset</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000342" class="method-detail">
        <a name="M000342"></a>

        <div class="method-heading">
          <a href="#M000342" class="method-signature">
          <span class="method-name">create_example_group</span><span class="method-args">(*args, &amp;block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000342-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000342-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/example/example_group_factory.rb, line 43</span>
43:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create_example_group</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
44:           <span class="ruby-identifier">opts</span> = <span class="ruby-constant">Hash</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span> <span class="ruby-value">? </span><span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span> <span class="ruby-operator">:</span> {}
45:           <span class="ruby-identifier">superclass</span> = <span class="ruby-identifier">determine_superclass</span>(<span class="ruby-identifier">opts</span>)
46:           <span class="ruby-identifier">superclass</span>.<span class="ruby-identifier">describe</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
47:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000340" class="method-detail">
        <a name="M000340"></a>

        <div class="method-heading">
          <a href="#M000340" class="method-signature">
          <span class="method-name">default</span><span class="method-args">(example_group_class)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Sets the <a href="ExampleGroupFactory.html#M000340">default</a> <a
href="ExampleGroup.html">ExampleGroup</a> class
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000340-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000340-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/example/example_group_factory.rb, line 29</span>
29:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">default</span>(<span class="ruby-identifier">example_group_class</span>)
30:           <span class="ruby-identifier">old</span> = <span class="ruby-ivar">@example_group_types</span>
31:           <span class="ruby-ivar">@example_group_types</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">example_group_class</span>)
32:           <span class="ruby-ivar">@example_group_types</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">old</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">old</span>
33:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000341" class="method-detail">
        <a name="M000341"></a>

        <div class="method-heading">
          <a href="#M000341" class="method-signature">
          <span class="method-name">get</span><span class="method-args">(key=nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000341-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000341-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/example/example_group_factory.rb, line 35</span>
35:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get</span>(<span class="ruby-identifier">key</span>=<span class="ruby-keyword kw">nil</span>)
36:           <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@example_group_types</span>.<span class="ruby-identifier">values</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">key</span>)
37:             <span class="ruby-identifier">key</span>
38:           <span class="ruby-keyword kw">else</span>
39:             <span class="ruby-ivar">@example_group_types</span>[<span class="ruby-identifier">key</span>]
40:           <span class="ruby-keyword kw">end</span>
41:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000339" class="method-detail">
        <a name="M000339"></a>

        <div class="method-heading">
          <a href="#M000339" class="method-signature">
          <span class="method-name">register</span><span class="method-args">(key, example_group_class)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Registers an example group class <tt>klass</tt> with the symbol
<tt>type</tt>. For example:
</p>
<pre>
  Spec::Example::ExampleGroupFactory.register(:farm, FarmExampleGroup)
</pre>
<p>
With that you can append a hash with :type =&gt; :farm to the describe
method and it will load an instance of FarmExampleGroup.
</p>
<pre>
  describe Pig, :type =&gt; :farm do
    ...
</pre>
<p>
If you don&#8216;t use the hash explicitly, <tt>describe</tt> will
implicitly use an instance of FarmExampleGroup for any file loaded from the
<tt>./spec/farm</tt> directory.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000339-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000339-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/example/example_group_factory.rb, line 24</span>
24:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">register</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">example_group_class</span>)
25:           <span class="ruby-ivar">@example_group_types</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">example_group_class</span>
26:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000338" class="method-detail">
        <a name="M000338"></a>

        <div class="method-heading">
          <a href="#M000338" class="method-signature">
          <span class="method-name">reset</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000338-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000338-source">
<pre>
   <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/example/example_group_factory.rb, line 5</span>
5:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reset</span>
6:           <span class="ruby-ivar">@example_group_types</span> = <span class="ruby-keyword kw">nil</span>
7:           <span class="ruby-identifier">default</span>(<span class="ruby-constant">ExampleGroup</span>)
8:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Protected Class methods</h3>

      <div id="method-M000343" class="method-detail">
        <a name="M000343"></a>

        <div class="method-heading">
          <a href="#M000343" class="method-signature">
          <span class="method-name">determine_superclass</span><span class="method-args">(opts)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000343-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000343-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/example/example_group_factory.rb, line 51</span>
51:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">determine_superclass</span>(<span class="ruby-identifier">opts</span>)
52:           <span class="ruby-identifier">key</span> = <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:type</span>]
53:             <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:type</span>]
54:           <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:spec_path</span>] <span class="ruby-operator">=~</span> <span class="ruby-node">/spec(\\|\/)(#{@example_group_types.keys.join('|')})/</span>
55:             <span class="ruby-identifier">$2</span> <span class="ruby-operator">==</span> <span class="ruby-value str">''</span> <span class="ruby-operator">?</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">$2</span>.<span class="ruby-identifier">to_sym</span>
56:           <span class="ruby-keyword kw">end</span>
57:           <span class="ruby-identifier">get</span>(<span class="ruby-identifier">key</span>)
58:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>